import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

/**
 * 角色训练记录实体
 */
@Entity("character_training")
@ManualTimestamp()
export class CharacterTrainingEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column({ name: "character_id" })
  characterId!: number;

  @Column({ name: "training_hours", default: 0 })
  trainingHours!: number;

  @Column({ name: "total_training_hours", default: 0 })
  totalTrainingHours!: number;

  @Column({ name: "last_training_time", type: "datetime", nullable: true })
  lastTrainingTime?: Date;

  @Column({ name: "is_training", default: false })
  isTraining!: boolean;

  @Column({ name: "training_start_time", type: "datetime", nullable: true })
  trainingStartTime?: Date;

  @Column({ name: "training_end_time", type: "datetime", nullable: true })
  trainingEndTime?: Date;

  @Column({
    name: "training_status",
    default: 0,
    comment: "训练状态：0-未开始，1-训练中，2-已完成",
  })
  trainingStatus!: number;

  @Column({
    name: "pending_exp",
    type: "bigint",
    default: 0,
    comment: "本次训练可领取的经验（1207记录，1208领取）",
  })
  pendingExp!: number;

  @Column("datetime", { comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", { comment: "更新时间" })
  updated_at!: Date;
}
